function isObject(value) {
  let valueType = typeof value;
  return value !== null && (valueType == "object" || valueType == "function");
}

function deepCopy(originValue) {
  if (!isObject(originValue)) {
    return originValue;
  }
  let newObject = {};
  for (let key in originValue) {
    newObject[key] = deepCopy(originValue[key]);
  }
  return newObject;
}

let obj = {
  name: "xjh",
  friend: {
    age: 10,
    address: {
      place: "上海",
    },
  },
};

let newObj = deepCopy(obj);

console.log(newObj === obj);
obj.friend.address.place = "北京";
console.log(newObj.friend.address.place);
console.log(obj.friend.address.place);
